<template>
	<view class="pageview">
		<cl-navbar :title="$t('astral.index.title')" leftIconSize="40rpx"
			friendicon placeholder usericon>
		</cl-navbar>
		<view class="searchview">
			<u-search height="64rpx" :showAction="false" :clearabled="false" bgColor="#ffffff" :inputStyle="{fontSize:'24rpx'}" :placeholder="$t('commonality.search')" @input="searchInput"></u-search>
		</view>

		<view class="box">
			<u-swiper radius="40rpx" :list="swiperlist">
				<template v-slot:image="{ item, index }">
					<cl-stars-image :srckey="item.image_url" ></cl-stars-image>
				</template>
			</u-swiper>
			<view class="list">
				<view class="list-items" v-for="(item, index) in searchlist" :key="index" @click="godetails(item)">
					<view class="">
						<cl-stars-image :srckey="item.cover_url" imageStyle="width: 290rpx;height: 260rpx;border-radius: 20px;"></cl-stars-image>
					</view>
					<view class="section">
						<view>
							<view class="section__topview">
								<text class="section__topview__nickname" v-html="item.nick_name"></text>
								<text class="section__topview__time">{{$t('astral.index.makingFriends')}}</text>
							</view>
							<view class="section__tagview">
								<view class="section__tagview__tag" v-for="(tag,idx) in item.label_names" :key="index+'tag'+idx" :style="{backgroundColor:tagcolors[idx % tagcolors.length]}">
									<text class="section__tagview__tag__text" >{{tag}}</text>
								</view>
							</view>
						</view>
						<text class="section__detail u-line-1" v-html="item.lanhutext6"></text>
						<view class="section__bottomview">
							<view class="section__bottomview__imgview">
								<cl-stars-image :srckey="image"  imageStyle="width: 70rpx;height: 70rpx;border-radius: 5px;" v-for="(image,imgidx) in item.images" :key="imgidx"></cl-stars-image>
							</view>
							<view class="section__bottomview__callview">
								<text class="section__bottomview__callview__text" >{{$t('astral.index.orderNow')}}</text>
								<image class="section__bottomview__callview__xin" src="/static/icon/dazhaohuxin.svg" />
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<cl-tabbar :currentTab="1"></cl-tabbar>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				tagcolors:['#FF605F','#2356AD','#4B9E39','#DFA32E'],
				swiperlist: [],
				astralList:[],
				constants: {},
				searchval:''
			};
		},
		onLoad() {
			uni.hideTabBar()
			this.getList()
		},
		computed:{
			searchlist(){
				let newdata = this.astralList.filter(item => {
					// 根据名字筛选
					if (this.searchval && item.nick_name.indexOf(this.searchval) === -1) {
						return false;
					}
					return true;
				});
				return newdata
			}
		},
		methods: {
			searchInput(e){
				uni.$u.debounce(()=>{
					this.searchval = e
				}, 500,false)
			},
			getList(){
				this.$api.common.StarsBanner({banner_type:1}).then(res=>{
					if(res){
						this.swiperlist = res.data.list
					}
				})
				this.$api.common.showUserList().then(res=>{
					if(res){
						this.astralList = res.data.list || []
					}
				})
			},
			godetails(item){
				this.$Router.push({
					name:'astraldetails',
					params: {
						id:item.id
					}
				})
			}
		},
	};
</script>
<style lang="scss">
	.pageview {
		height: 100vh;
		display: flex;
		flex-direction: column;

		.searchview {
			margin: 20rpx 30rpx;
			background-color: #ffffff;
			border-radius: 60rpx;
			padding-right: 20rpx;
		}

		.box {
			flex: 1;
			overflow: auto;
			padding: 0 30rpx;
			.list {
				margin: 20rpx 0 0 0;

				.list-items {
					background-color: rgba(30, 31, 48, 1);
					border-radius: 20px;
					margin-bottom: 30rpx;
					display: flex;
					.section {
						margin: 20rpx 0 15rpx 0;
						padding: 0 25rpx 0 20rpx;
						display: flex;
						flex: 1;
						overflow: hidden;
						flex-direction: column;
						justify-content: space-between;

						&__topview {
							display: flex;
							justify-content: space-between;
							&__nickname {
								overflow-wrap: break-word;
								color: #fff;
								font-size: 28rpx;
							}
							&__time {
								color: #61626e;
								font-size: 20rpx;
							}
						}

						&__tagview {
							display: flex;
							gap: 10rpx;
							margin-top: 10rpx;
							&__tag {
								display: flex;
								border-radius: 11px;
								padding: 3rpx 10rpx;
								&__text {
									overflow-wrap: break-word;
									color: rgba(255, 255, 255, 1);
									font-size: 20rpx;
								}
							}
						}
						&__detail{
							overflow-wrap: break-word;
							color: #61626E;
							font-size: 24rpx;
						}
						
						&__bottomview{
							display: flex;
							flex-direction: row;
							justify-content: space-between;
							&__imgview{
								display: flex;
								gap: 10rpx;
							}
							&__callview {
								background-color: rgba(18, 19, 37, 1);
								border-radius: 10px;
								position: relative;
								padding: 8rpx 20rpx 8rpx 20rpx;
								align-self: flex-end;
								display: flex;
								align-items: center;
								justify-content: center;
								&__text {
									background-image: linear-gradient(180deg,
											rgba(255, 255, 255, 1) 0,
											rgba(182, 139, 77, 1) 100%);
									overflow-wrap: break-word;
									color: rgba(255, 255, 255, 1);
									font-size: 24rpx;
									-webkit-background-clip: text;
									-webkit-text-fill-color: transparent;
								}
							
								&__xin {
									position: absolute;
									right: 0rpx;
									top: -25rpx;
									width: 40rpx;
									height: 40rpx;
								}
							}
						}
					}
				}
			}
		}
	}

	button {
		margin: 0;
		padding: 0;
		border: 1px solid transparent;
		outline: none;
		background-color: transparent;
	}

	button:active {
		opacity: 0.6;
	}
</style>